Skip to content

fix(model): anthorpic stream thinking event#1943

Merged
chickenlj merged 1 commit into
agentscope-ai:mainfrom
rudy2steiner:anthropic_thinking_response_parse
Jul 6, 2026
Merged

fix(model): anthorpic stream thinking event#1943
chickenlj merged 1 commit into
agentscope-ai:mainfrom
rudy2steiner:anthropic_thinking_response_parse

Conversation

@rudy2steiner

Copy link
Copy Markdown
Contributor

Summary
Fixes #1636 by parsing Anthropic streaming thinking_delta events into AgentScope ThinkingBlock content blocks. Non-streaming thinking blocks were already supported; this adds
parity for streamed responses.

Changes

  • Added delta().thinking() handling in AnthropicResponseParser.parseStreamEvent(...).
  • Converts Anthropic ThinkingDelta content into io.agentscope.core.message.ThinkingBlock.
  • Added regression coverage for streaming thinking deltas using RawContentBlockDeltaEvent.builder().thinkingDelta(...).

@rudy2steiner rudy2steiner requested a review from a team June 26, 2026 14:47
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@jujn jujn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes missing support for Anthropic streaming thinking_delta events by parsing them into AgentScope ThinkingBlock content blocks, bringing streaming behavior in line with the already-supported non-streaming thinking blocks.

Changes:

  • Added handling for delta().thinking() in AnthropicResponseParser.parseStreamEvent(...) to emit ThinkingBlock chunks.
  • Added a regression unit test that builds a RawContentBlockDeltaEvent with thinkingDelta(...) and verifies parsing behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
agentscope-extensions/agentscope-extensions-model/agentscope-extensions-model-anthropic/src/main/java/io/agentscope/extensions/model/anthropic/formatter/AnthropicResponseParser.java Adds streamed thinking delta parsing into ThinkingBlock during content-block delta events.
agentscope-extensions/agentscope-extensions-model/agentscope-extensions-model-anthropic/src/test/java/io/agentscope/extensions/model/anthropic/formatter/AnthropicResponseParserTest.java Adds regression coverage ensuring thinkingDelta stream events produce a ThinkingBlock with expected content.

@chickenlj chickenlj merged commit 3b44b2c into agentscope-ai:main Jul 6, 2026
6 checks passed
zouyx pushed a commit to zouyx/agentscope-java that referenced this pull request Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AnthropicResponseParser stream doesn't support thinkingblocks 为什么流式方式调用不支持提取 thinking 内容

4 participants